package cn.bgs.service.impl;

import cn.bgs.MD5.MD5Util;
import cn.bgs.dao.EmpMapper;
import cn.bgs.dao.StuMapper;
import cn.bgs.pojo.EmployeeRegister;
import cn.bgs.pojo.Student;
import cn.bgs.pojo.StudentRegister;
import cn.bgs.pojo.Vo;
import cn.bgs.service.EmpService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class EmpServiceImpl implements EmpService {

    Logger log = LogManager.getLogger();

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private StuMapper stuMapper;


    @Override
    public EmployeeRegister denglu(String email, String password) {
        //密文加密
        return empMapper.denglu(email,MD5Util.code(password));

//        return empMapper.denglu(email,password);
    }



    @Override
    public int zhuce2(Vo vo) {

        return empMapper.zhuce2(vo);
    }

    @Override
    public int zhuce(Vo vo) {
        //自动生成永不重复id
        String replace = UUID.randomUUID().toString().replace("-", " ");//随机英文+数字
        vo.setEmployeeId(replace);

        //密文加密
        String password = vo.getPassword();
        vo.setPassword(MD5Util.code(password));

        return empMapper.zhuce(vo);
    }

    //学生登录
    @Override
    public StudentRegister stuLogin(String email, String password) {
        return empMapper.stuLogin(email,password);
    }

//    @Override
//    public Student selStu(String stuNum) {
//        return stuMapper.selStuInfo(stuNum);
//    }


}
